package fr.afcepf.atod.loaning.services.implementations;

import javax.jws.WebService;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import fr.afcepf.atod.loaning.services.IBorrowingCalculator;

@WebService(endpointInterface="fr.afcepf.atod.loaning.services.IBorrowingCalculator")
class BorrowingCalculator implements IBorrowingCalculator {
	
	@SuppressWarnings("unused")
	private static Logger logger = LoggerFactory.getLogger(BorrowingCalculator.class);

	@Override
	public double getMonthlyFee(double mount, int nb_month, double month_rate_pct) {
		
		double monthlyRate = month_rate_pct / 100;
		
		return mount * monthlyRate / (1 - Math.pow(1.0+monthlyRate, -nb_month));
	}

}
